home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 1998 November / IRIX 6.5.2 Base Documentation November 1998.img / usr / share / catman / p_man / cat3 / perl5 / Math::Trig.z / Math::Trig
Text File  |  1998-10-30  |  8KB  |  265 lines

  1.  
  2.  
  3.  
  4. MMMMaaaatttthhhh::::::::TTTTrrrriiiigggg((((3333))))                                                    MMMMaaaatttthhhh::::::::TTTTrrrriiiigggg((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      Math::Trig - trigonometric functions
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.              use Math::Trig;
  13.  
  14.              $x = tan(0.9);
  15.              $y = acos(3.7);
  16.              $z = asin(2.4);
  17.  
  18.              $halfpi = pi/2;
  19.  
  20.              $rad = deg2rad(120);
  21.  
  22.  
  23. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  24.      Math::Trig defines many trigonometric functions not defined by the core
  25.      Perl which defines only the sin() and cos().  The constant ppppiiii is also
  26.      defined as are a few convenience functions for angle conversions.
  27.  
  28. TTTTRRRRIIIIGGGGOOOONNNNOOOOMMMMEEEETTTTRRRRIIIICCCC FFFFUUUUNNNNCCCCTTTTIIIIOOOONNNNSSSS
  29.      The tangent
  30.  
  31.              tan
  32.  
  33.      The cofunctions of the sine, cosine, and tangent (cosec/csc and cotan/cot
  34.      are aliases)
  35.  
  36.              csc cosec sec cot cotan
  37.  
  38.      The arcus (also known as the inverse) functions of the sine, cosine, and
  39.      tangent
  40.  
  41.              asin acos atan
  42.  
  43.      The principal value of the arc tangent of y/x
  44.  
  45.              atan2(y, x)
  46.  
  47.      The arcus cofunctions of the sine, cosine, and tangent (acosec/acsc and
  48.      acotan/acot are aliases)
  49.  
  50.              acsc acosec asec acot acotan
  51.  
  52.      The hyperbolic sine, cosine, and tangent
  53.  
  54.              sinh cosh tanh
  55.  
  56.      The cofunctions of the hyperbolic sine, cosine, and tangent (cosech/csch
  57.      and cotanh/coth are aliases)
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. MMMMaaaatttthhhh::::::::TTTTrrrriiiigggg((((3333))))                                                    MMMMaaaatttthhhh::::::::TTTTrrrriiiigggg((((3333))))
  71.  
  72.  
  73.  
  74.              csch cosech sech coth cotanh
  75.  
  76.      The arcus (also known as the inverse) functions of the hyperbolic sine,
  77.      cosine, and tangent
  78.  
  79.              asinh acosh atanh
  80.  
  81.      The arcus cofunctions of the hyperbolic sine, cosine, and tangent
  82.      (acsch/acosech and acoth/acotanh are aliases)
  83.  
  84.              acsch acosech asech acoth acotanh
  85.  
  86.      The trigonometric constant ppppiiii is also defined.
  87.  
  88.              $pi2 = 2 * pi;
  89.  
  90.  
  91.      EEEERRRRRRRROOOORRRRSSSS DDDDUUUUEEEE TTTTOOOO DDDDIIIIVVVVIIIISSSSIIIIOOOONNNN BBBBYYYY ZZZZEEEERRRROOOO
  92.  
  93.      The following functions
  94.  
  95.              tan
  96.              sec
  97.              csc
  98.              cot
  99.              asec
  100.              acsc
  101.              tanh
  102.              sech
  103.              csch
  104.              coth
  105.              atanh
  106.              asech
  107.              acsch
  108.              acoth
  109.  
  110.      cannot be computed for all arguments because that would mean dividing by
  111.      zero or taking logarithm of zero. These situations cause fatal runtime
  112.      errors looking like this
  113.  
  114.              cot(0): Division by zero.
  115.              (Because in the definition of cot(0), the divisor sin(0) is 0)
  116.              Died at ...
  117.  
  118.      or
  119.  
  120.              atanh(-1): Logarithm of zero.
  121.              Died at...
  122.  
  123.      For the csc, cot, asec, acsc, acot, csch, coth, asech, acsch, the
  124.      argument cannot be 0 (zero).  For the atanh, acoth, the argument cannot
  125.      be 1 (one).  For the atanh, acoth, the argument cannot be -1 (minus one).
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. MMMMaaaatttthhhh::::::::TTTTrrrriiiigggg((((3333))))                                                    MMMMaaaatttthhhh::::::::TTTTrrrriiiigggg((((3333))))
  137.  
  138.  
  139.  
  140.      For the tan, sec, tanh, sech, the argument cannot be _p_i/_2 + _k * _p_i, where
  141.      _k is any integer.
  142.  
  143.      SSSSIIIIMMMMPPPPLLLLEEEE ((((RRRREEEEAAAALLLL)))) AAAARRRRGGGGUUUUMMMMEEEENNNNTTTTSSSS,,,, CCCCOOOOMMMMPPPPLLLLEEEEXXXX RRRREEEESSSSUUUULLLLTTTTSSSS
  144.  
  145.      Please note that some of the trigonometric functions can break out from
  146.      the rrrreeeeaaaallll aaaaxxxxiiiissss into the ccccoooommmmpppplllleeeexxxx ppppllllaaaannnneeee. For example asin(2) has no
  147.      definition for plain real numbers but it has definition for complex
  148.      numbers.
  149.  
  150.      In Perl terms this means that supplying the usual Perl numbers (also
  151.      known as scalars, please see the _p_e_r_l_d_a_t_a manpage) as input for the
  152.      trigonometric functions might produce as output results that no more are
  153.      simple real numbers: instead they are complex numbers.
  154.  
  155.      The Math::Trig handles this by using the Math::Complex package which
  156.      knows how to handle complex numbers, please see the _M_a_t_h::_C_o_m_p_l_e_x manpage
  157.      for more information. In practice you need not to worry about getting
  158.      complex numbers as results because the Math::Complex takes care of
  159.      details like for example how to display complex numbers. For example:
  160.  
  161.              print asin(2), "\n";
  162.  
  163.      should produce something like this (take or leave few last decimals):
  164.  
  165.              1.5707963267949-1.31695789692482i
  166.  
  167.      That is, a complex number with the real part of approximately 1.571 and
  168.      the imaginary part of approximately -1.317.
  169.  
  170. AAAANNNNGGGGLLLLEEEE CCCCOOOONNNNVVVVEEEERRRRSSSSIIIIOOOONNNNSSSS
  171.      (Plane, 2-dimensional) angles may be converted with the following
  172.      functions.
  173.  
  174.              $radians  = deg2rad($degrees);
  175.              $radians  = grad2rad($gradians);
  176.  
  177.              $degrees  = rad2deg($radians);
  178.              $degrees  = grad2deg($gradians);
  179.  
  180.              $gradians = deg2grad($degrees);
  181.              $gradians = rad2grad($radians);
  182.  
  183.      The full circle is 2 _p_i radians or _3_6_0 degrees or _4_0_0 gradians.
  184.  
  185. BBBBUUUUGGGGSSSS
  186.      Saying use Math::Trig; exports many mathematical routines in the caller
  187.      environment and even overrides some (sin, cos).  This is construed as a
  188.      feature by the Authors, actually... ;-)
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. MMMMaaaatttthhhh::::::::TTTTrrrriiiigggg((((3333))))                                                    MMMMaaaatttthhhh::::::::TTTTrrrriiiigggg((((3333))))
  203.  
  204.  
  205.  
  206.      The code is not optimized for speed, especially because we use
  207.      Math::Complex and thus go quite near complex numbers while doing the
  208.      computations even when the arguments are not. This, however, cannot be
  209.      completely avoided if we want things like asin(2) to give an answer
  210.      instead of giving a fatal runtime error.
  211.  
  212. AAAAUUUUTTTTHHHHOOOORRRRSSSS
  213.      Jarkko Hietaniemi <_j_h_i@_i_k_i._f_i> and Raphael Manfredi
  214.      <_R_a_p_h_a_e_l__M_a_n_f_r_e_d_i@_g_r_e_n_o_b_l_e._h_p._c_o_m>.
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.